package com.nmgsr.nettools.util;

/**
 * Project:android_91Battle
 * Author:qmc
 * Description:
 * Time:2020/7/6 10: 32
 */
public class StringUtils {

    //数字
    public static final String REG_NUMBER = ".*\\d+.*";
    //小写字母
    public static final String REG_UPPERCASE = ".*[A-Z]+.*";
    //大写字母
    public static final String REG_LOWERCASE = ".*[a-z]+.*";
    //特殊符号(~!@#$%^&*()_+|<>,.?/:;'[]{}\)
    public static final String REG_SYMBOL = ".*[~!@#$%^&*()_+|<>,.?/:;'\\[\\]{}\"]+.*";

    /**
     * 验证首字母
     *
     * @param charAt the char at
     * @return the boolean
     */
    public static boolean firstStrVerify(char charAt) {
        if (charAt >= 'a' && charAt <= 'z' || charAt >= 'A' && charAt <= 'Z' || charAt >= '0' && charAt <= '9') {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 必须有大小写英文，数字，符号起码有2种
     *
     * @param pwd the pwd
     * @return the boolean
     */
    public static boolean matchesPwd(String pwd){
        if(pwd.matches(REG_NUMBER)&&pwd.matches(REG_UPPERCASE)){
            return true;
        }
        if(pwd.matches(REG_NUMBER)&&pwd.matches(REG_LOWERCASE)){
            return true;
        }
        if(pwd.matches(REG_NUMBER)&&pwd.matches(REG_SYMBOL)){
            return true;
        }
        if(pwd.matches(REG_UPPERCASE)&&pwd.matches(REG_LOWERCASE)){
            return true;
        }
        if(pwd.matches(REG_UPPERCASE)&&pwd.matches(REG_SYMBOL)){
            return true;
        }
        if(pwd.matches(REG_LOWERCASE)&&pwd.matches(REG_SYMBOL)){
            return true;
        }
        return false;
    }

}
